home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-10-01 | 21.2 KB | 579 lines | [TEXT/MPS ] |
- {
- File: HFSVolumesPriv.p
-
- Contains: On-disk data structures for HFS and HFS Plus volumes.
-
- Version: Technology:
- Release: 8.1a3c2
-
- Copyright: © 1984-1997 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: Please include the the file and version information (from above) with
- the problem description. Developers belonging to one of the Apple
- developer programs can submit bug reports to:
-
- devsupport@apple.com
-
- }
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := 0}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT HFSVolumesPriv;
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED __HFSVOLUMESPRIV__}
- {$SETC __HFSVOLUMESPRIV__ := 1}
-
- {$I+}
- {$SETC HFSVolumesPrivIncludes := UsingIncludes}
- {$SETC UsingIncludes := 1}
-
- {$IFC UNDEFINED __TYPES__}
- {$I Types.p}
- {$ENDC}
- {$IFC UNDEFINED __FILES__}
- {$I Files.p}
- {$ENDC}
- {$IFC UNDEFINED __FINDER__}
- {$I Finder.p}
- {$ENDC}
-
-
-
- {$PUSH}
- {$ALIGN MAC68K}
- {$LibExport+}
-
- { Signatures used to differentiate between HFS and HFS Plus volumes }
-
- CONST
- kHFSSigWord = $4244; { 'BD' in ASCII }
- kHFSPlusSigWord = $482B; { 'H+' in ASCII }
- kHFSPlusVersion = $0003; { will change as format changes }
- kHFSPlusMountVersion = '8.01'; { will change as implementations change }
-
-
- { CatalogNodeID is used to track catalog objects }
-
- TYPE
- CatalogNodeID = UInt32;
- { Unicode strings are used for file and folder names (HFS Plus only) }
- UniStr255Ptr = ^UniStr255;
- UniStr255 = RECORD
- length: UInt16; { number of unicode characters }
- unicode: ARRAY [0..254] OF UniChar; { unicode characters }
- END;
-
- ConstUniStr255Param = ^UniStr255;
-
- CONST
- kHFSMaxVolumeNameChars = 27;
- kHFSMaxFileNameChars = 31;
- kHFSPlusMaxFileNameChars = 255;
- CMMaxCName = 31; { •• this will go away }
-
-
- { Extent overflow file data structures }
- { Small Extent key (HFS only) }
-
- TYPE
- SmallExtentKeyPtr = ^SmallExtentKey;
- SmallExtentKey = RECORD
- keyLength: SInt8; { length of key, excluding this field }
- forkType: SInt8; { 0 = data fork, FF = resource fork }
- fileID: CatalogNodeID; { file ID }
- startBlock: UInt16; { first file allocation block number in this extent }
- END;
-
- { Large Extent key (HFS Plus only) }
- LargeExtentKeyPtr = ^LargeExtentKey;
- LargeExtentKey = RECORD
- keyLength: UInt16; { length of key, excluding this field }
- forkType: SInt8; { 0 = data fork, FF = resource fork }
- pad: SInt8; { make the other fields align on 32-bit boundary }
- fileID: CatalogNodeID; { file ID }
- startBlock: UInt32; { first file allocation block number in this extent }
- END;
-
- { Universal Extent Key }
- ExtentKeyPtr = ^ExtentKey;
- ExtentKey = RECORD
- CASE INTEGER OF
- 0: (
- small: SmallExtentKey;
- );
- 1: (
- large: LargeExtentKey;
- );
- END;
-
-
- CONST
- kSmallExtentDensity = 3;
- kLargeExtentDensity = 8;
-
- { Small extent descriptor (HFS only) }
-
- TYPE
- SmallExtentDescriptorPtr = ^SmallExtentDescriptor;
- SmallExtentDescriptor = RECORD
- startBlock: UInt16; { first allocation block }
- blockCount: UInt16; { number of allocation blocks }
- END;
-
- { Large extent descriptor (HFS Plus only) }
- LargeExtentDescriptorPtr = ^LargeExtentDescriptor;
- LargeExtentDescriptor = RECORD
- startBlock: UInt32; { first allocation block }
- blockCount: UInt32; { number of allocation blocks }
- END;
-
- { Universal extent descriptor }
- ExtentDescriptorPtr = ^ExtentDescriptor;
- ExtentDescriptor = RECORD
- CASE INTEGER OF
- 0: (
- small: SmallExtentDescriptor;
- );
- 1: (
- large: LargeExtentDescriptor;
- );
- END;
-
- { Small extent record (HFS only) }
- SmallExtentRecord = ARRAY [0..2] OF SmallExtentDescriptor;
- { Large extent record (HFS Plus only) }
- LargeExtentRecord = ARRAY [0..7] OF LargeExtentDescriptor;
- { Universal extent record }
- ExtentRecordPtr = ^ExtentRecord;
- ExtentRecord = RECORD
- CASE INTEGER OF
- 0: (
- small: SmallExtentRecord;
- );
- 1: (
- large: LargeExtentRecord;
- );
- END;
-
-
- { Fork data info (HFS Plus only) - 80 bytes }
- ForkDataPtr = ^ForkData;
- ForkData = RECORD
- logicalSize: UInt64; { fork's logical size in bytes }
- clumpSize: UInt32; { fork's clump size in bytes }
- totalBlocks: UInt32; { total blocks used by this fork }
- extents: LargeExtentRecord; { initial set of extents }
- END;
-
- { Permissions info (HFS Plus only) - 16 bytes }
- PermissionsPtr = ^Permissions;
- Permissions = RECORD
- ownerID: UInt32; { user or group ID of file/folder owner }
- groupID: UInt32; { additional user of group ID }
- permissions: UInt32; { permissions (bytes: unused, owner, group, everyone) }
- specialDevice: UInt32; { UNIX: device for character or block special file }
- END;
-
- { Catalog file data structures }
-
- CONST
- kHFSRootParentID = 1; { Parent ID of the root folder }
- kHFSRootFolderID = 2; { Folder ID of the root folder }
- kHFSExtentsFileID = 3; { File ID of the extents file }
- kHFSCatalogFileID = 4; { File ID of the catalog file }
- kHFSBadBlockFileID = 5; { File ID of the bad allocation block file }
- kHFSAllocationFileID = 6; { File ID of the allocation file (HFS Plus only) }
- kHFSStartupFileID = 7; { File ID of the startup file (HFS Plus only) }
- kHFSAttributesFileID = 8; { File ID of the attribute file (HFS Plus only) }
- kBogusExtentFileID = 15; { Used for exchanging extents in extents file }
- kFirstFreeCatalogNodeID = 16;
-
-
- { Small catalog key (HFS only) }
-
- TYPE
- SmallCatalogKeyPtr = ^SmallCatalogKey;
- SmallCatalogKey = RECORD
- keyLength: SInt8; { key length (in bytes) }
- reserved: SInt8; { reserved (set to zero) }
- parentID: CatalogNodeID; { parent folder ID }
- nodeName: Str31; { catalog node name }
- END;
-
- { Large catalog key (HFS Plus only) }
- LargeCatalogKeyPtr = ^LargeCatalogKey;
- LargeCatalogKey = RECORD
- keyLength: UInt16; { key length (in bytes) }
- parentID: CatalogNodeID; { parent folder ID }
- nodeName: UniStr255; { catalog node name }
- END;
-
- { Universal catalog key }
- CatalogKeyPtr = ^CatalogKey;
- CatalogKey = RECORD
- CASE INTEGER OF
- 0: (
- small: SmallCatalogKey;
- );
- 1: (
- large: LargeCatalogKey;
- );
- END;
-
-
- { Catalog record types }
-
- CONST
- { HFS Catalog Records }
- kSmallFolderRecord = $0100; { Folder record }
- kSmallFileRecord = $0200; { File record }
- kSmallFolderThreadRecord = $0300; { Folder thread record }
- kSmallFileThreadRecord = $0400; { File thread record }
- { HFS Plus Catalog Records }
- kLargeFolderRecord = 1; { Folder record }
- kLargeFileRecord = 2; { File record }
- kLargeFolderThreadRecord = 3; { Folder thread record }
- kLargeFileThreadRecord = 4; { File thread record }
-
-
- { Catalog file record flags }
- kFileLockedBit = $0000; { file is locked and cannot be written to }
- kFileLockedMask = $0001;
- kFileThreadExistsBit = $0001; { a file thread record exists for this file }
- kFileThreadExistsMask = $0002;
-
-
- { Small catalog folder record (HFS only) - 70 bytes }
-
- TYPE
- SmallCatalogFolderPtr = ^SmallCatalogFolder;
- SmallCatalogFolder = RECORD
- recordType: SInt16; { record type }
- flags: UInt16; { folder flags }
- valence: UInt16; { folder valence }
- folderID: CatalogNodeID; { folder ID }
- createDate: UInt32; { date and time of creation }
- modifyDate: UInt32; { date and time of last modification }
- backupDate: UInt32; { date and time of last backup }
- userInfo: DInfo; { Finder information }
- finderInfo: DXInfo; { additional Finder information }
- reserved: ARRAY [0..3] OF UInt32; { reserved - set to zero }
- END;
-
- { Large catalog folder record (HFS Plus only) - 88 bytes }
- LargeCatalogFolderPtr = ^LargeCatalogFolder;
- LargeCatalogFolder = RECORD
- recordType: SInt16; { record type = HFS Plus folder record }
- flags: UInt16; { file flags }
- valence: UInt32; { folder's valence (limited to 2^16 in Mac OS) }
- folderID: CatalogNodeID; { folder ID }
- createDate: UInt32; { date and time of creation }
- contentModDate: UInt32; { date and time of last content modification }
- modifyDate: UInt32; { date and time of last modification (any kind) }
- accessDate: UInt32; { date and time of last access (Rhapsody only) }
- backupDate: UInt32; { date and time of last backup }
- permissions: Permissions; { permissions (for Rhapsody) }
- userInfo: DInfo; { Finder information }
- finderInfo: DXInfo; { additional Finder information }
- textEncoding: UInt32; { hint for name conversions }
- reserved: UInt32; { reserved - set to zero }
- END;
-
- { Small catalog file record (HFS only) - 102 bytes }
- SmallCatalogFilePtr = ^SmallCatalogFile;
- SmallCatalogFile = RECORD
- recordType: SInt16; { record type }
- flags: SInt8; { file flags }
- fileType: SInt8; { file type (unused ?) }
- userInfo: FInfo; { Finder information }
- fileID: CatalogNodeID; { file ID }
- dataStartBlock: UInt16; { not used - set to zero }
- dataLogicalSize: SInt32; { logical EOF of data fork }
- dataPhysicalSize: SInt32; { physical EOF of data fork }
- rsrcStartBlock: UInt16; { not used - set to zero }
- rsrcLogicalSize: SInt32; { logical EOF of resource fork }
- rsrcPhysicalSize: SInt32; { physical EOF of resource fork }
- createDate: UInt32; { date and time of creation }
- modifyDate: UInt32; { date and time of last modification }
- backupDate: UInt32; { date and time of last backup }
- finderInfo: FXInfo; { additional Finder information }
- clumpSize: UInt16; { file clump size (not used) }
- dataExtents: SmallExtentRecord; { first data fork extent record }
- rsrcExtents: SmallExtentRecord; { first resource fork extent record }
- reserved: UInt32; { reserved - set to zero }
- END;
-
- { Large catalog file record (HFS Plus only) - 248 bytes }
- LargeCatalogFilePtr = ^LargeCatalogFile;
- LargeCatalogFile = RECORD
- recordType: SInt16; { record type = HFS Plus file record }
- flags: UInt16; { file flags }
- reserved1: UInt32; { number of links (normally just one) }
- fileID: CatalogNodeID; { file ID }
- createDate: UInt32; { date and time of creation }
- contentModDate: UInt32; { date and time of last content modification }
- modifyDate: UInt32; { date and time of last modification (any kind) }
- accessDate: UInt32; { date and time of last access (Rhapsody only) }
- backupDate: UInt32; { date and time of last backup }
- permissions: Permissions; { permissions (for Rhapsody) }
- userInfo: FInfo; { Finder information }
- finderInfo: FXInfo; { additional Finder information }
- textEncoding: UInt32; { hint for name conversions }
- reserved2: UInt32; { reserved - set to zero }
- { start on double long (64 bit) boundry }
- dataFork: ForkData; { size and block data for data fork }
- resourceFork: ForkData; { size and block data for resource fork }
- END;
-
- { Small catalog thread record (HFS only) - 46 bytes }
- SmallCatalogThreadPtr = ^SmallCatalogThread;
- SmallCatalogThread = RECORD
- recordType: SInt16; { record type }
- reserved: ARRAY [0..1] OF SInt32; { reserved - set to zero }
- parentID: CatalogNodeID; { parent ID for this catalog node }
- nodeName: Str31; { name of this catalog node }
- END;
-
- { Large catalog thread record (HFS Plus only) -- 264 bytes }
- LargeCatalogThreadPtr = ^LargeCatalogThread;
- LargeCatalogThread = RECORD
- recordType: SInt16; { record type }
- reserved: SInt16; { reserved - set to zero }
- parentID: CatalogNodeID; { parent ID for this catalog node }
- nodeName: UniStr255; { name of this catalog node (variable length) }
- END;
-
- { Universal catalog data record }
- CatalogRecordPtr = ^CatalogRecord;
- CatalogRecord = RECORD
- CASE INTEGER OF
- 0: (
- recordType: SInt16;
- );
- 1: (
- smallFolder: SmallCatalogFolder;
- );
- 2: (
- smallFile: SmallCatalogFile;
- );
- 3: (
- smallThread: SmallCatalogThread;
- );
- 4: (
- largeFolder: LargeCatalogFolder;
- );
- 5: (
- largeFile: LargeCatalogFile;
- );
- 6: (
- largeThread: LargeCatalogThread;
- );
- END;
-
- {
- Key for records in the attributes file. Fields are compared in the order:
- cnid, attributeName, startBlock
- }
- AttributeKeyPtr = ^AttributeKey;
- AttributeKey = RECORD
- keyLength: UInt16; { must set kBTBigKeysMask and kBTVariableIndexKeysMask in BTree header's attributes }
- pad: UInt16;
- cnid: CatalogNodeID; { file or folder ID }
- startBlock: UInt32; { block # relative to start of attribute }
- attributeName: UniStr255; { variable length }
- END;
-
- {
- These are the types of records in the attribute B-tree. The values were chosen
- so that they wouldn't conflict with the catalog record types.
- }
-
- CONST
- kAttributeInlineData = $10; { if size < kAttrOverflowSize }
- kAttributeForkData = $20; { if size >= kAttrOverflowSize }
- kAttributeExtents = $30; { overflow extents for large attributes }
-
-
- {
- AttributeInlineData
- For small attributes, whose entire value is stored within this one
- B-tree record. The key for this record is of the form:
- ( CNID, name, 0 ). (startBlock == 0)
- There would not be any other records for this attribute.
- }
-
- TYPE
- AttributeInlineDataPtr = ^AttributeInlineData;
- AttributeInlineData = RECORD
- recordType: UInt32; { = kAttributeInlineData }
- logicalSize: UInt32; { size in bytes of userData }
- userData: PACKED ARRAY [0..1] OF Byte; { variable length; space allocated is a multiple of 2 bytes }
- END;
-
- {
- AttributeForkData
- For larger attributes, whose value is stored in allocation blocks.
- The key for this record is of the form:
- ( CNID, name, 0 ). (startBlock == 0)
- If the attribute has more than 8 extents, there will be additonal
- records (of type AttributeExtents) for this attribute.
- }
- AttributeForkDataPtr = ^AttributeForkData;
- AttributeForkData = RECORD
- recordType: UInt32; { = kAttributeForkData }
- reserved: UInt32;
- theFork: ForkData; { size and first extents of value }
- END;
-
- {
- AttributeExtents
- This record contains information about overflow extents for large,
- fragmented attributes. The key for this record is of the form:
- ( CNID, name, !=0 ). (startBlock != 0)
- The startBlock field of the key is the first allocation block number
- (relative to the start of the attribute value) represented by the
- extents in this record.
- }
- AttributeExtentsPtr = ^AttributeExtents;
- AttributeExtents = RECORD
- recordType: UInt32; { = kAttributeExtents }
- reserved: UInt32;
- extents: LargeExtentRecord; { additional extents }
- END;
-
- { A generic Attribute Record }
- AttributeRecordPtr = ^AttributeRecord;
- AttributeRecord = RECORD
- CASE INTEGER OF
- 0: (
- recordType: UInt32;
- );
- 1: (
- inlineData: AttributeInlineData;
- );
- 2: (
- forkData: AttributeForkData;
- );
- 3: (
- overflowExtents: AttributeExtents;
- );
- END;
-
- { Key and node lengths }
-
- CONST
- kLargeExtentKeyMaximumLength = 10;
- kSmallExtentKeyMaximumLength = 7;
- kLargeCatalogKeyMaximumLength = 516;
- kLargeCatalogKeyMinimumLength = 6;
- kSmallCatalogKeyMaximumLength = 37;
- kSmallCatalogKeyMinimumLength = 6;
- kAttributeKeyMaximumLength = 522;
- kAttributeKeyMinimumLength = 12;
- kLargeCatalogMinimumNodeSize = 4096;
- kLargeExtentMinimumNodeSize = 512;
- kAttributeMinimumNodeSize = 4096;
-
-
- { Bits 0-6 are reserved (always cleared by MountVol call) }
- kVolumeHardwareLockBit = 7; { volume is locked by hardware }
- kVolumeUnmountedBit = 8; { volume was successfully unmounted }
- kVolumeSparedBlocksBit = 9; { volume has bad blocks spared }
- kVolumeNoCacheRequiredBit = 10; { don't cache volume blocks (i.e. RAM or ROM disk) }
- kBootVolumeInconsistentBit = 11; { boot volume is inconsistent (System 7.6) }
- { Bits 12-14 are reserved for future use }
- kVolumeSoftwareLockBit = 15; { volume is locked by software }
- kVolumeHardwareLockMask = $80;
- kVolumeUnmountedMask = $0100;
- kVolumeSparedBlocksMask = $0200;
- kVolumeNoCacheRequiredMask = $0400;
- kBootVolumeInconsistentMask = $0800;
- kVolumeSoftwareLockMask = $8000;
- kMDBAttributesMask = $8380;
-
-
- { Master Directory Block (HFS only) - 162 bytes }
- { Stored at sector #2 (3rd sector) }
-
- TYPE
- MasterDirectoryBlockPtr = ^MasterDirectoryBlock;
- MasterDirectoryBlock = RECORD
- drSigWord: UInt16; { volume signature }
- drCrDate: UInt32; { date and time of volume creation }
- drLsMod: UInt32; { date and time of last modification }
- drAtrb: UInt16; { volume attributes }
- drNmFls: SInt16; { number of files in root folder }
- drVBMSt: UInt16; { first block of volume bitmap }
- drAllocPtr: UInt16; { start of next allocation search }
- drNmAlBlks: UInt16; { number of allocation blocks in volume }
- drAlBlkSiz: SInt32; { size (in bytes) of allocation blocks }
- drClpSiz: SInt32; { default clump size }
- drAlBlSt: SInt16; { first allocation block in volume }
- drNxtCNID: UInt32; { next unused catalog node ID }
- drFreeBks: SInt16; { number of unused allocation blocks }
- drVN: Str27; { volume name }
- { Master Directory Block extensions for HFS }
- drVolBkUp: UInt32; { date and time of last backup }
- drVSeqNum: UInt16; { volume backup sequence number }
- drWrCnt: SInt32; { volume write count }
- drXTClpSiz: SInt32; { clump size for extents overflow file }
- drCTClpSiz: SInt32; { clump size for catalog file }
- drNmRtDirs: SInt16; { number of directories in root folder }
- drFilCnt: SInt32; { number of files in volume }
- drDirCnt: SInt32; { number of directories in volume }
- drFndrInfo: ARRAY [0..7] OF SInt32; { information used by the Finder }
- drEmbedSigWord: UInt16; { embedded volume signature (formerly drVCSize) }
- drEmbedExtent: SmallExtentDescriptor; { embedded volume location and size (formerly drVBMCSize and drCtlCSize) }
- drXTFlSize: SInt32; { size of extents overflow file }
- drXTExtRec: SmallExtentRecord; { extent record for extents overflow file }
- drCTFlSize: SInt32; { size of catalog file }
- drCTExtRec: SmallExtentRecord; { extent record for catalog file }
- END;
-
- { VolumeHeader (HFS Plus only) - 512 bytes }
- { Stored at sector #0 (1st sector) and last sector }
- VolumeHeaderPtr = ^VolumeHeader;
- VolumeHeader = RECORD
- signature: UInt16; { volume signature == 'H+' }
- version: UInt16; { current version is kHFSPlusVersion }
- attributes: UInt32; { volume attributes }
- lastMountedVersion: UInt32; { implementation version which last mounted volume }
- reserved: UInt32; { reserved - set to zero }
- createDate: UInt32; { date and time of volume creation }
- modifyDate: UInt32; { date and time of last modification }
- backupDate: UInt32; { date and time of last backup }
- checkedDate: UInt32; { date and time of last disk check }
- fileCount: UInt32; { number of files in volume }
- folderCount: UInt32; { number of directories in volume }
- blockSize: UInt32; { size (in bytes) of allocation blocks }
- totalBlocks: UInt32; { number of allocation blocks in volume (includes this header and VBM }
- freeBlocks: UInt32; { number of unused allocation blocks }
- nextAllocation: UInt32; { start of next allocation search }
- rsrcClumpSize: UInt32; { default resource fork clump size }
- dataClumpSize: UInt32; { default data fork clump size }
- nextCatalogID: CatalogNodeID; { next unused catalog node ID }
- writeCount: UInt32; { volume write count }
- encodingsBitmap: UInt64; { which encodings have been use on this volume }
- finderInfo: PACKED ARRAY [0..31] OF UInt8; { information used by the Finder }
- allocationFile: ForkData; { allocation bitmap file }
- extentsFile: ForkData; { extents B-tree file }
- catalogFile: ForkData; { catalog B-tree file }
- attributesFile: ForkData; { extended attributes B-tree file }
- startupFile: ForkData; { boot file }
- END;
-
- {$ALIGN RESET}
- {$POP}
-
- {$SETC UsingIncludes := HFSVolumesPrivIncludes}
-
- {$ENDC} {__HFSVOLUMESPRIV__}
-
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-